<template>
  <div>
  
      <MySearch @parentbatch="parentbatch" @parentsearchFun="parentsearchFun"/>
      <!--  -->
      <MyTable @parentShowFun="parentShowFun" ref="batchTable" :financeArr="financeArr" @delFinanceFun="getFinanceList" />
      <MyPage :total="total" @resetPageFun="getFinanceList"/>
      <MyDialog v-if="isShow" @parentChange="getFinanceList" :dialogRow="dialogRow" @parentClose="parentClose" />
  </div>
</template>

<script>
import MySearch from '../Finance/components/MySearch.vue'
import MyTable from '../Finance/components/MyTable.vue'
import MyPage from '../Finance/components/MyPage.vue'
import MyDialog from '../Finance/components/MyDialog'
import { getFinanceApi } from '../../api/financeApi'
export default {
  data() {
    return {
      financeArr:[],
      searchVal:'',//搜索关键字
      page:1,
      pageSize:100,
      total:0,
      isShow:false,
      dialogRow:{}
    }
  },
  components:{
    MySearch, 
    MyTable,
    MyPage,
    MyDialog
  },
  mounted() {
    this.getFinanceList() //发送请求
  },
  methods: {
    // 修改
    parentShowFun(row){
      this.isShow=true
      this.dialogRow = row
      // console.log('this.dialogRow',this.dialogRow);

    },
    parentClose(){
      this.isShow=false
    },
    //批量删除
    parentbatch(){  //子调用父组件的批量删除函数
      this.$refs.batchTable.batchFun() //调用子组件中的函数
    }, 
    parentsearchFun(val){
      // 接收数据
      this.searchVal=val
      // console.log('++++++',this.searchVal);
      // 刷新表格
      this.getFinanceList()
    },
    getFinanceList(params){
      // 发请求 拿数据 保存到当前数组中
      var params = {
        searchVal:this.searchVal,//搜索关键字
        page:this.page,//当前页
        pageSize:this.pageSize//每页多少条
        }
      getFinanceApi(params).then(res=>{
        if(res.code===200){
          console.log('------',res);
          this.financeArr=res.data
          this.total=res.total
        }
      })

    }
  },


}
</script>

<style>

</style>